package springbootsession.springsession.bx;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class HelloController {
    @Value("${server.port}")
    Integer port;

    @GetMapping("/set/{id}")
    public String set(HttpSession session, @PathVariable String id) {
        session.setAttribute("user", "zyr"+id);
        return String.valueOf(port)+"---"+id;
    }
    @GetMapping("/get")
    public String get(HttpSession session) {

        return session.getAttribute("user") +"-------"+ port;

    }
}